﻿using System;
using MTC.Common;

namespace MTC.Web
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            Logging.Start();
            Logging.Info(Globals.ApplicationStart);

        }

        protected void Session_Start(object sender, EventArgs e)
        {
            Logging.Info(Globals.SessionStart);
        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {
            Exception ex = Server.GetLastError();
            Logging.Fatal(ex.Message, ex);

        }

        protected void Session_End(object sender, EventArgs e)
        {
            Session.Abandon();
            Logging.Info((Globals.SessionEnd));

        }

        protected void Application_End(object sender, EventArgs e)
        {
            // Code that runs on application shutdown
            Logging.Info(Globals.ApplicationEnd);
            Logging.Shutdown();

        }
    }
}